﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.HtmlControls;

namespace Ciripescu_WebRole
{
    public class BasePageAnonAndLoggedIn : System.Web.UI.Page
    {
        
        public BasePageAnonAndLoggedIn()
        {
            this.PreInit += new System.EventHandler(ChangeMasterPage);
        }

        private void ChangeMasterPage(object sender, System.EventArgs args)
        {
            if (Session["UserName"] == null)
                MasterPageFile = "~/Master/anon.master";
            else
                MasterPageFile = "~/Master/loggedin.master";
        }
        protected void Redirect301(string url)
        {
            Response.Status = "301 Moved Permanently";
            Response.AddHeader("Location", url);
            Response.End();
        }
        protected void SetMetaName(string name, string content)
        {
            HtmlMeta tag = new HtmlMeta();
            tag.Name = name;
            tag.Content = content;
            Header.Controls.Add(tag);
        }
        protected void SetMetaHttpEquiv(string HttpEquiv, string content)
        {
            HtmlMeta tag = new HtmlMeta();
            tag.HttpEquiv = HttpEquiv;
            tag.Content = content;
            Header.Controls.Add(tag);
        }

        /// <summary>
        /// Sets the meta keywords for the current page - for SEO purposes
        /// </summary>
        /// <param name="keywords">Keywords to set</param>
        protected void SetMetaKeywords(string keywords)
        {
            SetMetaName("keywords", keywords);

        }
        /// <summary>
        /// Sets the meta description for the current page - for SEO purposes
        /// </summary>
        /// <param name="descr">the description to set</param>
        protected void SetMetaDescription(string descr)
        {
            SetMetaName("description", descr);
        }
    }
}
